<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>编辑员工</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="../css/font.css">
<link rel="stylesheet" href="../css/xadmin.css">
<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/xadmin.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
</head> 
<body>
	<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form"  lay-filter="dataForm">
			
				<div class="layui-form-item">
					<label for="dictId" class="layui-form-label"> 
						<span class="x-red">*</span>编号
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sId" name="sId" autocomplete="off" readonly class="layui-input layui-disabled" >
					</div>
					
					<label for="dictType" class="layui-form-label"> 
						<span class="x-red">*</span>姓名
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sName" name="sName" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label for="dictItem" class="layui-form-label"> <span
						class="x-red">*</span>现住地址
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sAddress" name="sAddress" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
					<label for="dictValue" class="layui-form-label"> <span
						class="x-red">*</span>身份证
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sIdCard" name="sIdCard" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label for="dictItem" class="layui-form-label"> <span
						class="x-red">*</span>紧急联系人姓名
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sUrgencyName" name="sUrgencyName" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
					<label for="dictValue" class="layui-form-label"> <span
						class="x-red">*</span>紧急联系人电话
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sUrgencyPhone" name="sUrgencyPhone" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				
				<div class="layui-form-item">
					<label for="dictItem" class="layui-form-label"> <span
						class="x-red">*</span>密码
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sPwd" name="sPwd" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
					
				</div>


				<div class="layui-form-item">
					<label for="dictItem" class="layui-form-label"> <span
						class="x-red">*</span>员工出生日期
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sBirth" name="sBirth" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
					<label for="dictValue" class="layui-form-label"> <span
						class="x-red">*</span>员工银行卡号
					</label>
					<div class="layui-input-inline">
						<input type="text" id="sBankCard" name="sBankCard" required=""
							lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
				</div>
				
			</form>
		</div>
	</div>
	<script>
	
		//获取上个页面传递过来的 数据
		var rowsData = window.parent.formData;
		
		
		layui.use([ 'form', 'layer','layedit', 'laydate' ], function() {
			$ = layui.jquery;
			var form = layui.form, layer = layui.layer;
			
			//监听提交
			form.on('submit(add)', function(data) {
				console.log(data);
				if(!data.field["dictIsEditable"]){
					data.field["dictIsEditable"] = 2;
				}
				
				 
				 $.ajax({
		            //请求方式
		            type : "POST",
		            //请求的媒体类型
		            contentType: "application/json;charset=UTF-8",
		            //请求地址
		            url : "/toSalff/update",
		            //数据，(json字符串 JSON.stringify(data)),
		            data :  JSON.stringify(data.field),
		            //请求成功 
		            success : function(result) {
		            	if(result>0){
		            		//发异步，把数据提交给php
							layer.alert("修改成功", {
								icon : 6
							}, function() {
								// 获得frame索引
								var index = parent.layer.getFrameIndex(window.name);
								//关闭当前frame
								parent.layer.close(index);
								
								parent.location.reload();//刷新父页面更新修改后的表格数据
							});
		            	}else{
		            		//发异步，把数据提交给php
							layer.alert("修改失败！", {
								icon : 6
							});
		            	}
		            }
		        });
				return false;
			});
	
			//填充表达数据 dataForm 就是你form表达框的  lay-filter属性  lay-filter="dataForm"
			form.val('dataForm', { 
			      "sId": rowsData.sId // "name": "value"
			      ,"sName": rowsData.sName
			      ,"sBankCard": rowsData.sBankCard
			      ,"sUrgencyPhone": rowsData.sUrgencyPhone 
			      ,"sUrgencyName": rowsData.sUrgencyName //复选框选中状态(true 等于选择  false不选择)       因为数值是1和2 但是表单中的元素是复选框 ，1，我们不能直接赋值数值给它， 1已经是选中   2是不选择  
			      ,"sUrgencyPhone": rowsData.sUrgencyPhone 
			      ,"sAddress": rowsData.sAddress 
			      ,"sPwd": rowsData.sPwd 
			      ,"sIdCard": rowsData.sIdCard 
			      ,"sBirth": rowsData.sBirth 
			});
			
		});
	</script>
	<script>
		var _hmt = _hmt || [];
		(function() {
			var hm = document.createElement("script");
			hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
			var s = document.getElementsByTagName("script")[0];
			s.parentNode.insertBefore(hm, s);
		})();
	</script>
</body>

</html>